<template>
    <el-card>
        <!-- 面包屑 -->
        <div slot="header">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/home' }"> <i class="el-icon-house"></i> 首页</el-breadcrumb-item>
                <el-breadcrumb-item>权限管理</el-breadcrumb-item>
                <el-breadcrumb-item>权限列表</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <!-- 内容区域 -->
        
        <!-- 表格区域 -->
        <div class="table-box">
            <el-table :data="rightlist" border >
                <el-table-column label="序号" align="center" width="100" type="index"></el-table-column>
                <el-table-column label="ID" align="center" prop="id"></el-table-column>
                <el-table-column label="权限名称" align="center" prop="authName"></el-table-column>
                <el-table-column label="地址" align="center" prop="path"></el-table-column>
                <el-table-column label="层级" align="center" prop="level">
                    <template slot-scope="scope">
                        <el-tag type="danger" v-if="scope.row.level == 0" size="small" >一级</el-tag>
                        <el-tag type="primary" v-if="scope.row.level == 1" size="small">二级</el-tag>
                        <el-tag type="success" v-if="scope.row.level == 2"  size="small" >三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 树形表格 -->
            <!-- <el-table :data="rightlist" border row-key="id"  :tree-props="{ children:'children' }" >
                <el-table-column label="序号" align="center" width="100" type="index"></el-table-column>
                <el-table-column label="ID" align="center" prop="id"></el-table-column>
                <el-table-column label="权限名称" align="center" prop="authName"></el-table-column>
                <el-table-column label="地址" align="center" prop="path"></el-table-column>
            </el-table> -->
            
        </div>

    </el-card>
</template>

<script>
    export default {
        data() {
            return {
                rightlist: []  // 权限列表
            }
        },
        created () {
            this.getRightList()
        },
        methods: {
            async getRightList() {
                // 发送请求
                // let { data:res } = await this.$axios.get('rights/tree')
                let { data:res } = await this.$axios.get('rights/list')
                // 错误处理
                if(res.meta.status !== 200) return this.$message.error(res.meta.msg)
                // 成功赋值
                this.rightlist = res.data
            }
        },
    }
</script>

<style lang="less" scoped>

</style>